<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <h2>{{ phone | formatPhone }}</h2>
        <h2>{{time |  formatTime }} </h2>
    </div>
</body>
</html>
<script src="./vue-2.5.21.js"></script>
<script>
    //定义全局过滤器
    Vue.filter('formatPhone',(p)=>{
        return p.slice(0,3)+"****"+p.slice(-4)
    })
    Vue.filter('formatTime',(t)=>{
        return `${t.getFullYear()}-${t.getMonth()+1}-${t.getDate()}`
    })
    var v = new Vue({
        el:'#app',
        data:{
            phone:'1369855777',
            time:new Date()
        },
        // filters:{//局部过滤器
        //  formatPhone(p){
        //     return p.slice(0,3) + "****" + p.slice(-4)
        //  },
        //  formatTime(t){
        //     return `${t.getFullYear()}-${t.getMonth()+1}-${t.getDate()}`;
        //  }   
        // }
    })
</script>